﻿namespace Dissemination.MVC.Repositories
{
    using System.Linq;
    using System.Collections.Generic;
    using Dissemination.MVC.Models;

    public class TestResultRepository : BaseRepository<TestResult>
    {
        public TestResultRepository()
        {
            EntityName = "TestResults";
        }

        public override List<TestResult> List()
        {
            return dataContext.TestResults.ToList();
        }

        public List<TestResult> ListBySeminarID(int seminarID)
        {
            return dataContext.TestResults.Where(tr => tr.Seminar.SeminarID == seminarID).ToList();
        }

        public Seminar GetSeminarByID(int seminarID)
        {
            return dataContext.Seminars.Include("TargetArea.Program").Include("TargetArea.Country").Include("Participants").Include("TestResults").FirstOrDefault(s => s.SeminarID == seminarID);
        }

        public override TestResult Get(int id)
        {
            return dataContext.TestResults.Include("Seminar").FirstOrDefault(tr => tr.TestResultID == id);
        }
    }
}
